// ignore_for_file: import_of_legacy_library_into_null_safe

import 'package:flutter/material.dart';
import 'package:flutter_layout/config/provider_manager.dart';
import 'package:flutter_layout/config/router_manger.dart';
import 'package:flutter_layout/generated/l10n.dart';
import 'package:flutter_layout/view_model/locale_model.dart';
import 'package:flutter_layout/view_model/theme_model.dart';
import 'package:flutter_localizations/flutter_localizations.dart';
import 'package:oktoast/oktoast.dart';
import 'package:provider/provider.dart';
import 'package:pull_to_refresh/pull_to_refresh.dart';

class WanandroidPage extends StatelessWidget {
  const WanandroidPage({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return OKToast(
        child: MultiProvider(
            providers: providers,
            child: Consumer2<ThemeModel, LocaleModel>(builder: (context, themeModel, localeModel, child) {
              return RefreshConfiguration(
                hideFooterWhenNotFull: true, //列表数据不满一页,不触发加载更多
                child: MaterialApp(
                  debugShowCheckedModeBanner: false,
                  theme: themeModel.themeData(),
                  darkTheme: themeModel.themeData(platformDarkMode: true),
                  locale: localeModel.locale,
                  localizationsDelegates: const [
                    S.delegate,
                    RefreshLocalizations.delegate, //下拉刷新
                    GlobalCupertinoLocalizations.delegate,
                    GlobalMaterialLocalizations.delegate,
                    GlobalWidgetsLocalizations.delegate
                  ],
                  supportedLocales: S.delegate.supportedLocales,
                  onGenerateRoute: MyRouter.generateRoute,
                  initialRoute: RouteName.splash,
                  // builder: (context, child) {
                  //   Widget error = Text('报错了');
                  //   if (child is Scaffold || child is Navigator) error = Scaffold(body: Center(child: error));
                  //   ErrorWidget.builder = (FlutterErrorDetails errorDetails) => error;
                  //   return child ?? Container();
                  // },
                ),
              );
            })));
  }
// }
// class WanandroidPage extends StatefulWidget {
//   const WanandroidPage({Key? key}) : super(key: key);

//   @override
//   _WanandroidPageState createState() => _WanandroidPageState();
// }

// class _WanandroidPageState extends State<WanandroidPage> {
//   @override
//   Widget build(BuildContext context) {
//     return Scaffold(
//       appBar: AppBar(
//         title: const Text(''),
//       ),
//       body: Container(
//         child: Text("玩安卓"),
//       ),
//     );
//   }
}
